/*
 * @Author: your name
 * @Date: 2021-12-24 16:22:29
 * @LastEditTime: 2021-12-24 19:27:07
 * @LastEditors: LAPTOP-6BH4BV49
 * @Description: In User Settings Edit
 * @FilePath: \my_weizheng\魏征\agent\src\utils\picker.js
 */


export const picker = (data, list) => {

    let arr = {
        newpro: '',
        pro: [],
        newcity: '',
        city: [],
        newarea: '',
        area: []
    }
    data.forEach(item => {
        if (item.value === list[0]) {
            arr = {
                ...arr,
                newpro: item.label,
                pro: item.children
            }
        }
    })
    arr.pro.length && arr.pro.forEach(item => {

        if (item.value === list[1]) {
            arr = {
                ...arr,
                newcity: item.label,
                city: item.children
            }
        }
    })

    arr.city.length && arr.city.forEach(item => {
        if (item.value === list[2]) {
            arr = {
                ...arr,
                newarea: item.label,
            }
        }
    })
    var reg = /省|自治区|市$/;
    return {
        prov: arr.newpro.replace(reg, ''),
        city: arr.newcity,
        district: arr.newarea
    }

}